/*
 * Copyright 2010 Joshua Smith and Nelson Llewellyn
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package norse.msg;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Base message sent from client to server to request one or more scans.
 * Carries ScanRequestIF objects for the plugin(s).
 */
//TODO: JavaDoc
@XmlRootElement(name = "NoRSeScanRequest")
public class NoRSeScanRequest implements ScanRequestIF
{
    //Required because of JAXB
    public NoRSeScanRequest()
    {
        submessages = new ArrayList<MessageIF>();
    }

    public NoRSeScanRequest(List<MessageIF> _messages)
    {
        if (_messages == null)
        {
            throw new IllegalArgumentException("Null parameter is invalid");
        }

        //Messages must be immutable, so create a defensive copy
        submessages = new ArrayList<MessageIF>(_messages);
    }

    @XmlAnyElement
    private List<MessageIF> submessages;

    public MessageIF getSubmessage(int _index)
    {
        //All messages must be immutable, so we can just return it
        return submessages.get(_index);
    }
}
